﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Web.DynamicData;

namespace badminton.DynamicData.FieldTemplates
{
    public partial class CourseGrading_EditField : System.Web.DynamicData.FieldTemplateUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                DropDownList1.Items.Add(new ListItem("0", "0"));
                DropDownList1.Items.Add(new ListItem("1", "1"));
                DropDownList1.Items.Add(new ListItem("2", "2"));
                DropDownList1.Items.Add(new ListItem("3", "3"));
                DropDownList1.Items.Add(new ListItem("4", "4"));
                DropDownList1.Items.Add(new ListItem("5", "6"));
            }
        }

        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);
            if (this.FieldValueString != null && FieldValueString.Trim().Length > 0)
            {
                this.DropDownList1.SelectedValue = FieldValueString.Trim();
            }
        }

        protected override void ExtractValues(IOrderedDictionary dictionary)
        {
            dictionary[Column.Name] = ConvertEditedValue(DropDownList1.Text);
        }

        public override Control DataControl
        {
            get
            {
                return DropDownList1;
            }
        }
    }
}
